#include <iostream>
#include "msg_quene.h"
#include "rasp_cmd.h"

using namespace std;

int main(int argc,char *argv[])
{
    
    struct msg_content_t msg_content = 
    {
        .target = FAN,
        .cmd = OFF,
    };
    struct msg_content_t msg_content_receive;

    if(argc != 2)
    {
        std::cout << "参数数量不正确" << std::endl;
        return -1;
    }

    if(*argv[1] == '0')
    {
        msg_quene_t msg(MSG_SERVER) ;
        if(msg.receive(msg_content_receive) < 0)
        {
            printf("msg receive error\n");
            return -1;
        }
        cout << msg_content_receive.target << endl;
        cout << msg_content_receive.cmd << endl;
    }
    else
    {
        msg_quene_t msg(MSG_CLIENT) ;
        if(msg.send(msg_content) < 0)
        {
            printf("msg send error\n");
        }
    }

    return 0;
}
